/*
 *  $Id: Land.cs 1195 2010-11-19 15:17:06Z thenn.erannor $
 *	This file is a part of Ragima CCG.
 *	(C) 2008 Ragima development group.
 *
 *	Licensed under the terms of the GNU GPL License version 2.
 *
 */

namespace Ragima {

    /// <summary>
    /// Призванная земля (территория)
    /// Содержит: ссылка на карту
    /// </summary>
    public class Land: SummonedObject {
        public readonly LandCard Card;

        public Land(Player owner, LandCard card): base(owner) {
            Card = card;
            Summary.SetDefaultAbilities(card);
            AddAffect(new NaturalAffect(card));
        }

        public override SummonableCard SummonCard { get { return Card; } }

        public int Number {
            get { return Owner != null ? Owner.Lands.IndexOf(this) : 0; }
        }

        /// <value>
        /// Текущее здоровье
        /// </value>
        public override int Health { get { return 1; } set { } }
        /// <value>
        /// Минимальное здоровье
        /// </value>
        public override int MinHealth { get { return 0; } }
        /// <value>
        /// Максимальное здоровье
        /// </value>
        public override int MaxHealth { get { return 0; } }

        /// <summary>
        /// Удалить местность
        /// </summary>
        public override void Remove() {
            Owner.RemoveLand(this, true);
        }

        public override void ReturnToHand() {
            base.ReturnToHand();
            Remove();
        }

        public override void MoveToPlayer(Player newOwner) {
            if (newOwner == Owner) return;
            Owner.RemoveLand(this, false);
            Game.Current.Log.Add(Resources.Game.ChangeControl, this, newOwner);
            SetOwner(newOwner);
            newOwner.AddLand(this);
        }

        public override void InstantDeath() {
            Remove();
        }

        public override void OnSummon() {
            base.OnSummon();
            Summary.DoLandSummon(this);
            GlobalSummary.DoLandSummon(this);
        }

        public override Region FindRegion() {
            return Owner != null ? Owner.Game.FindRegionBy(this) : null;
        }
    }
}